﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
public partial class View_MapViewChoose : System.Web.UI.Page
{
    private static int idBusStrip;
    private static int direction;
    private static ManageBusSchedule mnBusSchedule;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            mnBusSchedule = new ManageBusSchedule();
            if (string.IsNullOrEmpty(Request.QueryString["IDBusStrip"]) && string.IsNullOrEmpty(Request.QueryString["Direction"]))
            {
                
            }
            else
            {
                idBusStrip = int.TryParse(Request.QueryString["IDBusStrip"], out idBusStrip) ? idBusStrip : 0;
                direction = int.TryParse(Request.QueryString["Direction"], out direction) ? direction : 0;
            }
        }
    }

    [WebMethod()]
    public static BusStation getBusStationNewest()
    {
        String dir = "Chiều đi";
        if (direction == 1)
        {
            dir = "Chiều về";
        }
        DataSet ds = mnBusSchedule.getBusStationNewEst(dir, idBusStrip);  
        if (ds == null || ds.Tables[0].Rows.Count <= 0)
            return null;
        BusStation busStation= new BusStation();
        busStation.IDStation = Convert.ToInt32(ds.Tables[0].Rows[0][BusStationColumn.IDStation].ToString());
        busStation.StaionName = ds.Tables[0].Rows[0][BusStationColumn.StationName].ToString();
        busStation.Latitude = ds.Tables[0].Rows[0][BusStationColumn.Latitude].ToString();
        busStation.Longitude = ds.Tables[0].Rows[0][BusStationColumn.Longitude].ToString();
        return busStation;
    }
}